public class Pet {
    private String name;
    private int hunger;   // 饥饿度
    private int happiness; // 快乐度
    private int health;   // 健康度

    public Pet(String name) {
        this.name = name;
        this.hunger = 50;
        this.happiness = 50;
        this.health = 50;
    }

    // Getter 和 Setter 方法
    public String getName() {
        return name;
    }

    public int getHunger() {
        return hunger;
    }

    public int getHappiness() {
        return happiness;
    }

    public int getHealth() {
        return health;
    }

    // 显示状态
    public void render() {
        System.out.println("名称：" + name);
        System.out.println("饥饿度：" + hunger);
        System.out.println("快乐度：" + happiness);
        System.out.println("健康度：" + health);
    }
    public int limitValue(int value){
        return Math.max(0,Math.min(100,value));
    }
    public void feed(){
        hunger = limitValue(hunger-20);
        happiness = limitValue(happiness+5);
    }
    public void play(){
        hunger = limitValue(hunger+10);
        happiness = limitValue(happiness+15);
    }
    public void bathe(){
        hunger = limitValue(hunger+5);
        health = limitValue(health+15);
    }
}

